/**
 * 文件描述：pinia 文件, 用于充电站监控相关逻辑
 */

import { defineStore } from "pinia";
import { ref } from "vue";
import type { RowType } from "@/types/station"; // 假设你有一个 RowType 类型定义

export const useStationStore = defineStore("station", () => {
  // 创建初始存储数据 - 当前行的数据
  const rowData = ref<RowType>({
    name: "",
    id: "",
    city: "",
    fast: "",
    slow: "",
    status: 1,
    now: "",
    fault: "",
    person: "",
    tel: "",
  });

  //修改数据的方法
  const setRowData = (row: RowType) => {
    rowData.value = { ...rowData.value, ...row };
  };

  // 清空数据的方法
  const clearRowData = () => {
    rowData.value = {
      name: "",
      id: "",
      city: "",
      fast: "",
      slow: "",
      status: 1,
      now: "",
      fault: "",
      person: "",
      tel: "",
    };
  }; 
  

  return {
    rowData,
    setRowData,
    clearRowData
  };
});
